package com.hula.loan4u.adapter;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.hula.loan4u.R;
import com.hula.loan4u.base.MBaseRecyclerAdapter;
import com.hula.loan4u.base.MBaseViewHolder;
import com.hula.loan4u.bean.CategoryBean;
import com.hula.loan4u.utils.ImageLoaderUtil;

import butterknife.BindView;


public class HomeCategoryAdapter extends MBaseRecyclerAdapter<CategoryBean, HomeCategoryAdapter.ViewHolder> {
    public HomeCategoryAdapter(Context context) {
        super(context);
    }

    @Override
    protected void onBindViewHolderEX(ViewHolder holder, int position) {
        holder.setData(getItem(position));
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(mInflater, parent);
    }

    class ViewHolder extends MBaseViewHolder<CategoryBean> {

        @BindView(R.id.category_img)
        ImageView categoryImg;
        @BindView(R.id.category_name)
        TextView categoryName;

        public ViewHolder(LayoutInflater mInflater, ViewGroup parent) {
            super(mInflater, parent, R.layout.item_category);
        }

        @Override
        protected void initView() {

        }

        @Override
        public void setData(CategoryBean data) {
            if (data != null) {
                categoryName.setText(data.topic);
//                ImageLoaderUtil.showImage(categoryImg, AppCons.IMAGE_HOST + data.iconUrl + AppUtils.getQiNiuParam(100, 100), R.drawable.image_default);
                ImageLoaderUtil.showImage(categoryImg, data.iconUrl, R.drawable.image_default);
            }
        }
    }
}
